output = open("第二周第二课.txt", "w", encoding="utf-8")
content = """

#字符串的编码和解码
>>> a = "我爱python"
>>> a.encode("utf-8")
b'\xe6\x88\x91\xe7\x88\xb1python'
>>> b = a.encode("utf-8")
>>> b.decode("utf-8")
'我爱python'


#字符串的CRUD操作
#1、创建（create）
>>> a = "hello"
>>> a = a + "world"
>>> a
'helloworld'


>>> a = "hello"
>>> a += "world"
>>> a
'helloworld'


#2、检索
>>> a = "I love python"
>>> a[3]
'o'
>>> a.find("o")
3

>>> a = "12345.*****"
>>> a.startswith("12345")
True
>>> b = "*****_python"
>>> b.endswith("python")
True

#3、更新(update)
>>> a = "I love pythen"
>>> a.replace("en", "on")
'I love python'

>>> b = "apple, pear, banana, orange"
>>> b.split(",")
['apple', ' pear', ' banana', ' orange']

>>> c = b.split(",")
>>> ",".join(c)
'apple, pear, banana, orange'

#4、删除
>>> d = "     I love python      "
>>> d.strip()
'I love python'
>>> d.lstrip()
'I love python      '
>>> d.rstrip()
'     I love python'


#字符串的格式化输出
>>> a = "I"
>>> b = "love"
>>> c = "python"
>>> "{} {} {}".format(a, b, c)
'I love python'
>>> "{a} {b} {c}".format(a = "I", b = "love", c = "python")
'I love python'
>>> print(f"{a} {b} {c}")
I love python

>>> a = 2.71828
>>> "{:.3f}".format(a)
'2.718'


"""
output.write(content)
<<<<<<< HEAD
output.close()
=======
output.close()
>>>>>>> origin/master
